#ifndef TETRIS_H
#define TETRIS_H

#include <QWidget>
#include <QKeyEvent>
#include <QTimer>
#include "block.h"

class Tetris : public QWidget {
    Q_OBJECT

public:
    Tetris(QWidget *parent = nullptr);
    ~Tetris();

protected:
    void paintEvent(QPaintEvent *event) override;
    void keyPressEvent(QKeyEvent *event) override;

private slots:
    void gameLoop();

private:
    static constexpr int BoardWidth = 10;
    static constexpr int BoardHeight = 20;
    static constexpr int BlockSize = 30;

    QTimer *timer;
    Block currentBlock;
    QVector<QVector<int>> board;

    void clearFullLines();
    bool isColliding(const Block &block);
    void lockBlock();
    void spawnBlock();
};

#endif // TETRIS_H
